package com.cyy.dyeing.controller;

import com.cyy.dyeing.common.Result;
import com.cyy.dyeing.model.Info;
import com.cyy.dyeing.model.ProcessDef;
import com.cyy.dyeing.service.BaseService;
import com.cyy.dyeing.service.ProcessDefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: cyy
 * @Date: 2024/7/26
 */
@RestController
@RequestMapping("/base")
public class BaseController {

    @Autowired
    private BaseService baseService;

    @Autowired
    private ProcessDefService processDefService;

    /**
     * 按照信息类型获取基础信息
     * @return
     */
    @GetMapping("/info/{info_type}")
    public Result infoByType(@PathVariable("info_type") Integer info_type){
        List<Info> infoList = baseService.getInfoList(info_type);
        return Result.ok(infoList);
    }

    /**
     * 获取基础信息
     * @return
     */
    @GetMapping("/info")
    public Result infos(){
        List<Info> list = baseService.getInfoList();
        return Result.ok(list);
    }

    /**
     * 获取流程定义数据
     * @return
     */
    @GetMapping("/process-def")
    public Result processDefs(){
        List<ProcessDef> list = processDefService.list();
        return Result.ok(list);
    }

}
